<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/uploadPreview.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
<script type="text/javascript">

	var url;
	$(function(){
	 new uploadPreview({ UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow" });
	});
	
	function search(){
		$("#dg").datagrid('load',{
			"fmechanism":$("#f1").combobox("getValue"),
			"smechanism":$("#s2").combobox("getValue"),
			"tmechanism":$("#t3").combobox("getValue"),
			"posc":$("#p1").combobox("getValue"),
			"posn":$("#p2").combobox("getValue"),
			"starttime":$('#starttime').datetimebox('getValue'),
			"endtime":$('#endtime').datetimebox('getValue'),
			"state":$('#state').datetimebox('getValue')
		});
	};
	
	function deleteStaff(){
		var selectedRows=$("#dg").datagrid('getSelections');
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要删除的数据！");
			return;
		}
		var row=selectedRows[0];
		if(row.state!="正常"){
			$.messager.alert("系统提示","请选择一条状态正常的要删除的数据！");
			return;
		}
		$.messager.confirm("系统提示","您确认要删除<font color=blue>"+row.name+"</font>这个员工信息吗？",function(r){
			if(r){
				$.post("${pageContext.request.contextPath}/staff/delete.action",{changeState:"删除",id:row.id},function(result){
					if(result.success){
						$.messager.alert("系统提示","员工数据已成功删除！");
						$("#dg").datagrid("reload");
					}else{
						$.messager.alert("系统提示","员工数据删除失败！");
					}
				},"json");
			}
		});
		
	};
	
	
	function saveStaff(){
		$("#fm").form("submit",{
			url:url,
			success:function(result){
				var result=eval('('+result+')');
				if(result.success){
					$.messager.alert("系统提示","登记成功");
					closeDialog();
					$("#dg").datagrid("reload");
				}else{
					$.messager.alert("系统提示","登记失败");
					return;
				}
			}
		});
	};
	
	function openlookDialog(){
		var selectedRows=$("#dg").datagrid('getSelections');
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要查看的数据！");
			return;
		}
		var row=selectedRows[0];
		$("#dlg").dialog("open").dialog("setTitle","查看员工信息明细");
		$('#fm').form('load',row);
		 new uploadPreview({ UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow" });
		$("#imgShow").attr("src","${pageContext.request.contextPath}/"+row.img);
		$('#btn').linkbutton('disable');
		
	}
	
	function openModifyDialog(){
		
		var selectedRows=$("#dg").datagrid('getSelections');
		if(selectedRows.length!=1){
			$.messager.alert("系统提示","请选择一条要复核的数据！");
			return;
		}
		var row=selectedRows[0];
		if(row.state!="未复核"){
			$.messager.alert("系统提示","请选择一条要复核的数据！");
			return;
		}
		$("#dlg").dialog("open").dialog("setTitle","查看员工信息明细");
		$('#fm').form('load',row);
		 new uploadPreview({ UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow" });
		$("#imgShow").attr("src","${pageContext.request.contextPath}/"+row.img);
		$('#fmechanism').combobox('readonly', true);	// 启用只读模式
		$('#smechanism').combobox('readonly', true);	// 启用只读模式
		$('#tmechanism').combobox('readonly', true);	// 启用只读模式
		$('#posc').combobox('readonly', true);	// 启用只读模式
		$('#posn').combobox('readonly', true);	// 启用只读模式
		url="${pageContext.request.contextPath}/staff/change.action?changeState=1";
	}

	function closeDialog(){
		$("#dlg").dialog("close");
		$("#email").val("");
		$("#imgShow").removeAttr("src");
		 new uploadPreview({ UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow" });
		$("#fm").form("clear");
		$('#btn').linkbutton('enable');
		$('#fmechanism').combobox('readonly', false);	// 禁用只读模式
		$('#smechanism').combobox('readonly', false);	// 禁用只读模式
		$('#tmechanism').combobox('readonly', false);	// 禁用只读模式
		$('#posc').combobox('readonly', false);	// 禁用只读模式
		$('#posn').combobox('readonly', false);	// 禁用只读模式
	};
	
</script>
</head>
<body style="margin:1px;">
	<table id="dg" title="人力资源档案管理" class="easyui-datagrid"
	 fitColumns="true" pagination="true" rownumbers="true" singleSelect="true"
	 url="${pageContext.request.contextPath}/staff/getListByMap.action" fit="true" toolbar="#tb">
	 <thead>
	 	<tr>
	 		<th field="cb" checkbox="true" align="center"></th>
	 		<th field="id" width="50" align="center">档案编号</th>
	 		<th field="name" width="60" align="center">员工名字</th>
	 		<th field="gender" width="40" align="center">员工性别</th>
	 		<th field="fmechanism" width="85" align="center" >一级机构</th>
	 		<th field="smechanism" width="85" align="center">二级机构</th>
	 		<th field="tmechanism" width="85" align="center">三级机构</th>
	 		<th field="posn" width="80" align="center">职位名称</th>
	 		<th field="posc" width="50" align="center" hidden="true" >职位分类</th>
	 		<th field="title" width="50" align="center" hidden="true" >职称</th>
	 		<th field="email" width="50" align="center" hidden="true" >员工邮箱</th>
	 		<th field="phone" width="50" align="center" hidden="true" >员工电话</th>
	 		<th field="qq" width="50" align="center" hidden="true" >员工QQ</th>
	 		<th field="mobile" width="50" align="center" hidden="true" >员工手机</th>
	 		<th field="address" width="50" align="center" hidden="true" >员工地址</th>
	 		<th field="zipcode" width="50" align="center" hidden="true" >邮编</th>
	 		<th field="nationality" width="50" align="center" hidden="true" >国籍</th>
	 		<th field="birthplace" width="50" align="center" hidden="true" >出生地</th>
	 		<th field="birthday" width="50" align="center" hidden="true" >生日</th>
	 		<th field="nation" width="50" align="center" hidden="true" >民族</th>
	 		<th field="rebe" width="50" align="center" hidden="true" >宗教信仰</th>
	 		<th field="povi" width="50" align="center" hidden="true" >政治面貌</th>
	 		<th field="idcard" width="50" align="center" hidden="true" >身份证号码</th>
	 		<th field="sosenum" width="50" align="center" hidden="true" >社会保障号码</th>
	 		<th field="age" width="50" align="center" hidden="true" >年龄</th>
	 		<th field="education" width="50" align="center" hidden="true" >学历</th>
	 		<th field="educationyears" width="50" align="center" hidden="true" >教育年限</th>
	 		<th field="major" width="50" align="center" hidden="true" >学历专业</th>
	 		<th field="salarystandard" width="50" align="center" hidden="true" >薪酬标准</th>
	 		<th field="bankoa" width="50" align="center" hidden="true" >开户行</th>
	 		<th field="accountnumber" width="50" align="center" hidden="true" >账号</th>
	 		<th field="reviewer" width="50" align="center" hidden="true" >登记人</th>
	 		<th field="reviewtime" width="100" align="center" >建档时间</th>
	 		<th field="specialty" width="100" align="center" hidden="true" >特长</th>
	 		<th field="hobby" width="50" align="center" hidden="true" hidden="true" >爱好</th>
	 		<th field="personalresume" width="50" align="center" hidden="true">个人履历</th>
	 		<th field="familyrelationship" width="50" align="center" hidden="true">家庭关系信息</th>
	 		<th field="remark" width="50" align="center" hidden="true">备注</th>
	 		<th field="state" width="50" align="center" >状态</th>
	 		<th field="img" width="50" align="center" hidden="true">用户头像</th>
	 		<th field="reviewstatus" width="70" align="center" hidden="true">复核状态</th>
	 	</tr>
	 </thead> 
	</table>
	<div id="tb">
		<div>
			<a href="javascript:openModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">复核</a>
			<a href="javascript:deleteStaff()" class="easyui-linkbutton" iconCls="icon-cancel" plain="true">删除</a>
			<a href="javascript:openlookDialog()" class="easyui-linkbutton" iconCls="icon-tip" plain="true">查看详细</a>
		</div>
		<div>
			&nbsp;一级机构：&nbsp;<input class="easyui-combobox" name="fmechanism" id="f1" style="width: 148px;"
									data-options="
									url:'${pageContext.request.contextPath}/institution/get.action?parentid=0',
									valueField:'id',
									textField:'text',
									panelHeight:'auto',
									onSelect: function(rec){
						                $('#s2').combobox('clear');  
						                $('#t3').combobox('clear');  
						                var url = '${pageContext.request.contextPath}/institution/get.action?parentid='+rec.id ;
						                $('#s2').combobox('reload', url);
									}">
			&nbsp;二级机构：&nbsp;<input class="easyui-combobox" name="smechanism" id="s2" style="width: 148px;"
									data-options="
									valueField:'id',
									textField:'text',
									panelHeight:'auto',
									onSelect: function(rec){
						                $('#t3').combobox('clear');  
						                var url = '${pageContext.request.contextPath}/institution/get.action?parentid='+rec.id;
						                $('#t3').combobox('reload', url);
									}">
			&nbsp;三级机构：&nbsp;<input class="easyui-combobox" name="tmechanism" id="t3" style="width: 135px;"
									data-options="
									valueField:'id',
									textField:'text',
									panelHeight:'auto'">
			&nbsp;职位分类：&nbsp;<input class="easyui-combobox" name="posc" id="p1" style="width: 130px;"
									data-options="
									url:'${pageContext.request.contextPath}/position/get.action?parentid=0',
									valueField:'id',
									textField:'text',
									panelHeight:'auto',
									onSelect: function(rec){
						                $('#p2').combobox('clear');  
						                var url = '${pageContext.request.contextPath}/position/get.action?parentid='+rec.id;
						                $('#p2').combobox('reload', url);
									}">
			&nbsp;职位名称：&nbsp;<input class="easyui-combobox" name="posn" id="p2" style="width: 140px;"
									data-options="
									valueField:'id',
									textField:'text',
									panelHeight:'auto'
									">
			<br>
			&nbsp;建档时间：&nbsp;<input class="easyui-datetimebox" name="starttime" id="starttime" style="width: 148px;"></input>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：
			<input class="easyui-datetimebox" name="endtime" id="endtime" style="width: 148px;"></input>
			&nbsp;状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：&nbsp;
							<select id="state" class="easyui-combobox" name="state" panelHeight="auto" style="width: 134px;">
								<option value="" ></option>
								<option value="未复核" >未复核</option>
								<option value="正常">正常</option>
								<option value="已删除">已删除</option>
							</select>
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
		</div>
	</div>
	
	<div id="dlg" class="easyui-dialog" style="width: 990px;height:410px;"
	  closed="true"  closable="false" buttons="#dlg-buttons">
	 	<form id="fm"  enctype="multipart/form-data"  method="post">
	 		<table >
	 			<tr><td><input name="id" id="id" type="hidden"></td></tr>
	 			<tr>
	 				<td>一级机构：</td>
	 				<td><input class="easyui-combobox" name="fmechanism" id="fmechanism"
									data-options="
									url:'${pageContext.request.contextPath}/institution/get.action?parentid=0',
									valueField:'id',
									textField:'text',
									panelHeight:'auto',
									onSelect: function(rec){
						                $('#smechanism').combobox('clear');  
						                $('#tmechanism').combobox('clear');  
						                var url = '${pageContext.request.contextPath}/institution/get.action?parentid='+rec.id;
						                $('#smechanism').combobox('reload', url);
									}">
					</td>
	 				<td>二级机构：</td>
	 				<td><input class="easyui-combobox" name="smechanism" id="smechanism"
									data-options="
									valueField:'id',
									textField:'text',
									panelHeight:'auto',
									onSelect: function(rec){
						                $('#tmechanism').combobox('clear');  
						                var url = '${pageContext.request.contextPath}/institution/get.action?parentid='+rec.id;
						                $('#tmechanism').combobox('reload', url);
									}">
					</td>
					<td>三级机构：</td>
	 				<td><input class="easyui-combobox" name="tmechanism" id="tmechanism"
									data-options="
									valueField:'id',
									textField:'text',
									panelHeight:'auto'">
					</td>
					
	 			</tr>
	 			<tr>
	 				<td>职位分类：</td>
	 				<td><input class="easyui-combobox" name="posc" id="posc"
									data-options="
									url:'${pageContext.request.contextPath}/position/get.action?parentid=0',
									valueField:'id',
									textField:'text',
									panelHeight:'auto',
									onSelect: function(rec){
						                $('#posn').combobox('clear');  
						                var url = '${pageContext.request.contextPath}/position/get.action?parentid='+rec.id;
						                $('#posn').combobox('reload', url);
									}">
					</td>
	 				<td>职位名称：</td>
	 				<td><input class="easyui-combobox" name="posn" id="posn"
									data-options="
									valueField:'id',
									textField:'text',
									panelHeight:'auto',
									onSelect: function(rec){
						                $('#salarystandard').combobox('clear');  
						                var url = '${pageContext.request.contextPath}/salarystandard/get.action?id='+rec.standardid; 
						                $('#salarystandard').combobox('reload', url);
									}">
					</td>
					<td>职称：</td>
	 				<td><input class="easyui-combobox" name="title" id="title"
									data-options="
									url:'${pageContext.request.contextPath}/titles/get.action',
									valueField:'id',
									textField:'text',
									panelHeight:'auto'">
					</td>
					
	 			</tr>
	 			<tr>
	 				<td>姓名：</td>
	 				<td><input class="easyui-textbox" name="name" id="name"></td>
	 				<td>性别：</td>
	 				<td><select id="gender" class="easyui-combobox" name="gender" panelHeight="auto" style="width: 146px;">
							<option value="男" selected>男</option>
							<option value="女">女</option>
						</select>
					</td>
					<td>Email：</td>
	 				<td><input type="email" name="email" id="email">
					</td>
					
	 			</tr>
	 			<tr>
	 				<td>电话：</td>
	 				<td><input class="easyui-textbox" name="phone" id="phone"></td>
	 				<td>QQ：</td>
	 				<td><input class="easyui-textbox" name="qq" id="qq"></td>
	 				<td>手机：</td>
	 				<td><input class="easyui-textbox" name="mobile" id="mobile"></td>
	 			</tr>
	 			<tr>
	 				<td>住址：</td>
	 				<td colspan="3"><input class="easyui-textbox" name="address"  id="address" style="width: 356px;"></td>
	 				<td>邮编：</td>
	 				<td><input class="easyui-textbox" name="zipcode" id="zipcode"></td>
	 			</tr>
	 			<tr>
	 				<td>国籍：</td>
	 				<td><select id="nationality" class="easyui-combobox" name="nationality"  panelHeight="auto" style="width: 146px;">
							<option value="中国" selected>中国</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 				<td>出生地：</td>
	 				<td><input class="easyui-textbox" name="birthplace"  id="birthplace"></td>
	 				<td>生日：</td>
	 				<td><input class="easyui-datetimebox" name="birthday" id="birthday"></input></td>
	 				<td>民族：</td>
	 				<td><select id="nation" class="easyui-combobox" name="nation" panelHeight="auto" style="width: 146px;">
							<option value="汉族" selected>汉族</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 			</tr>
	 			<tr>
	 				<td>宗教信仰：</td>
	 				<td><select id="rebe" class="easyui-combobox" name="rebe" panelHeight="auto" style="width: 146px;">
							<option value="无" selected>无</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 				<td>政治面貌：</td>
	 				<td><select id="povi" class="easyui-combobox" name="povi" panelHeight="auto" style="width: 146px;">
							<option value="无" selected>无</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 				<td>身份证号码：</td>
	 				<td><input class="easyui-textbox" name="idcard" id="idcard"></td>
	 				<td>社会保障号码：</td>
	 				<td><input class="easyui-textbox" name="sosenum" id="sosenum"></td>
	 			</tr>
	 			<tr>
	 				<td>年龄：</td>
	 				<td><input class="easyui-numberbox"  name="age" id="age" data-options="min:0,max:100"></td>
	 				<td>学历：</td>
	 				<td><select id="education" class="easyui-combobox" name="education" panelHeight="auto" style="width: 146px;">
							<option value="中学">中学</option>
							<option value="本科" selected>本科</option>
							<option value="硕士">硕士</option>
							<option value="博士">博士</option>
						</select>
					</td>
	 				<td>教育年限：</td>
	 				<td><select id="educationyears" class="easyui-combobox" name="educationyears" panelHeight="auto" style="width: 146px;">
							<option value="9">9</option>
							<option value="12" >12</option>
							<option value="16" selected>16</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 				<td>学历专业：</td>
	 				<td><select id="major" class="easyui-combobox" name="major" panelHeight="auto" style="width: 146px;">
							<option value="计算机科学与技术">计算机科学与技术</option>
							<option value="软件工程" selected>软件工程</option>
							<option value="机械自动化">机械自动化</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 			</tr>
	 			<tr>
	 				<td>薪酬标准：</td>
	 				<td><input class="easyui-combobox" name="salarystandard" id="salarystandard"
									data-options="
									valueField:'id',
									textField:'text',
									panelHeight:'auto'">
					</td>
	 				<td>开户行：</td>
	 				<td><input class="easyui-textbox" name="bankoa"  id="bankoa"></td>
	 				<td>账号：</td>
	 				<td><input class="easyui-textbox" name="accountnumber"  id="accountnumber"></td>
	 				<td>变更人：</td>
	 				<td><input class="easyui-textbox" name="reviewer"  id="reviewer"  readonly="readonly" value="${currentAdmin.name }"></td>
	 			</tr>
	 			<tr>
	 				<td>登记时间：</td>
	 				<td><input class="text" name="reviewtime"  id="reviewtime"  readonly="readonly"  ></td>
	 				<td>特长：</td>
	 				<td><select id="specialty" class="easyui-combobox" name="specialty" panelHeight="auto" style="width: 146px;">
							<option value="计算机网络">计算机网络</option>
							<option value="数据库" selected>数据库</option>
							<option value="大数据">大数据</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 				<td>爱好：</td>
	 				<td><select id="hobby" class="easyui-combobox" name="hobby" panelHeight="auto" style="width: 146px;">
							<option value="篮球" selected>篮球</option>
							<option value="足球">足球</option>
							<option value="羽毛球">羽毛球</option>
							<option value="其他">其他</option>
						</select>
					</td>
	 			</tr>
	 			<tr>
	 				<td>上传个人头像：</td>
	 				<td colspan="6"> <input type="file" name="imgfile" id="up_img" /></td>
	 				<td colspan="5"> <div id="imgdiv"><img id="imgShow" width="120" height="120" /></div></td>
	 			</tr>
	 			<tr>
	 				<td valign="top">个人履历：</td>
	 				<td colspan="7">
	 					<textarea rows="3" cols="80" id="personalresume" name="personalresume" ></textarea>
	 				</td>
	 			</tr>
	 			<tr>
	 				<td valign="top">家庭关系：</td>
	 				<td colspan="7">
	 					<textarea rows="3" cols="80" id="familyrelationship" name="familyrelationship"></textarea>
	 				</td>
	 			</tr>
	 			<tr>
	 				<td valign="top">备注：</td>
	 				<td colspan="7">
	 					<textarea rows="3" cols="80" id="remark" name="remark"></textarea>
	 				</td>
	 			</tr>
	 		</table>
	 	</form>
	</div>
	
	<div id="dlg-buttons">
		<a href="javascript: saveStaff()" id="btn" class="easyui-linkbutton" iconCls="icon-ok">执行操作</a>
		<a href="javascript: closeDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
	</div>
</body>
</html>